import React from "react";

import { connect } from "react-redux";

const mapStateToProps = (state) => {
  return {
    name: state.name,
  };
};

const mapDispatchToProps = (dispatch) => {
  return {
    change() {
      dispatch({ type: "change", name: "lisi" });
    },
  };
};

const Child = (props) => {
  return (
    <div>
      <h4>child子组件</h4>
      <p>name: {props.name}</p>
      <button onClick={props.change}>change</button>
    </div>
  );
};

export default connect(mapStateToProps, mapDispatchToProps)(Child);
